home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / "kabooms" (global data info) ƒ / no kaboom ƒ / no kaboom.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  1.8 KB  |  97 lines  |  [TEXT/MPS ]

  1. /*    File: no kaboom.c
  2.     
  3.     C code for a simple printing extension.
  4.     
  5.     Dave Hersey
  6.     Apple Developer Technical Support
  7.  
  8.     2/01/93    - dmh - Created.
  9.     4/26/93    - dmh - Updated to use recommended approach,
  10.                     and work around b1 shutdown bug.
  11.     9/07/93 - dmh - Updated for b2.
  12.    12/18/93 - dmh - Updated for b3.
  13.     3/22/94 - dmh - Verified for b4.
  14.     6/14/96 - cn  - Updated to support Universal Interfaces 2.1.
  15. */
  16.  
  17. #include <Types.h>
  18. #include <Errors.h>
  19. #include <Resources.h>
  20. #include <ToolUtils.h>
  21. #include <GXMessages.h>
  22. #include <GXPrinting.h>
  23.  
  24. // external defines for creating our A5 world.
  25.  
  26. extern long A5Size (void);
  27. extern void A5Init (void *);
  28.  
  29.  
  30. #define r_str        200
  31. #define r_s1_idx    1
  32. #define r_s2_idx    2
  33. #define r_s3_idx    3
  34. #define r_s4_idx    4
  35.  
  36. // globals
  37.  
  38. Str255    s1;
  39. Str255    s2;
  40. Str255    s3;
  41. Str255    s4;
  42.  
  43. // InitGlobalData is used to initialize any global data we need to
  44. // in our message override.  It's critical that you do things this
  45. // way, rather than access the data in the same scope that you call
  46. // NewMessageGlobals.  Otherwise, some compilers will generate code
  47. // with invalid data references.
  48.  
  49. OSErr InitGlobalData()
  50. {
  51.     short    oldResFile;
  52.  
  53. // Initialize any global data here.
  54.  
  55.     oldResFile = CurResFile();
  56.     UseResFile(GXGetMessageHandlerResFile());
  57.  
  58.     GetIndString(s1, r_str, r_s1_idx);
  59.     GetIndString(s2, r_str, r_s2_idx);
  60.     GetIndString(s3, r_str, r_s3_idx);
  61.     GetIndString(s4, r_str, r_s4_idx);
  62.  
  63.     UseResFile(oldResFile);
  64.     return ResError();
  65. }
  66.  
  67.  
  68. OSErr MyStartJob(StringPtr docName, long pageCount)
  69. {
  70.     OSErr    err1, err2;
  71.     
  72.     err1 = NewMessageGlobals(A5Size(), A5Init);
  73.     if (!err1) err1 = InitGlobalData();
  74.  
  75.     err2 = Forward_GXStartJob(docName, pageCount);
  76.  
  77.     if (!err2)
  78.         err2 = err1;
  79.  
  80.     if (err2)
  81.         DisposeMessageGlobals();
  82.  
  83.     return err2;
  84. }
  85.  
  86.  
  87. OSErr MyFinishJob()
  88. {
  89.     DebugStr(s1);
  90.     DebugStr(s2);
  91.     DebugStr(s3);
  92.     DebugStr(s4);
  93.     
  94.     DisposeMessageGlobals();
  95.     return Forward_GXFinishJob();
  96. }
  97.